<?php

namespace common\models\patient;

use Yii;

/**
 * This is the model class for table "{{%patient_consumption_detail}}".
 *
 * @property int $id
 * @property int $consumption_id 消费记录ID
 * @property int $yiyuan_aid  奕远消费表id
 * @property string $patient_card_id 诊疗号
 * @property string $drug_name 药名
 * @property int $drug_num 数量
 * @property string $drug_unit 单位
 * @property string $drug_type 类型
 * @property float $price 单价
 * @property float $money 金额
 * @property int $project_id 项目id
 * @property float $discount_rate 折扣率（0.80,代表8折）
 * @property float $reality_money 折扣后金额
 * @property int $consumption_type 消费类型： 1：消费 2：入库（已退货）
 * @property string $remark 备注
 * @property int $event_at 发生时间
 * @property int $created_at 创建时间
 * @property int $updated_at 更新时间
 */
class ConsumptionDetail extends \common\models\BaseModel
{
    const CONSUMPTION_TYPE_BOOKED = 1;// 消费
    const CONSUMPTION_TYPE_REFUND = 2;// 入库【已退货】

    public static $consupmtionTypes = [
        self::CONSUMPTION_TYPE_BOOKED => '消费',
        self::CONSUMPTION_TYPE_REFUND => '入库',
    ];

    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%patient_consumption_detail}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['consumption_id', 'drug_num','yiyuan_aid', 'consumption_type', 'created_at', 'updated_at','event_at'], 'integer'],
            [['price', 'money', 'discount_rate', 'reality_money'], 'number'],
            [['patient_card_id'], 'string', 'max' => 50],
            [['drug_name'], 'string', 'max' => 100],
            [['drug_unit'], 'string', 'max' => 30],
            [['drug_type'], 'string', 'max' => 60],
            [['remark'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'consumption_id' => '消费记录ID',
            'patient_card_id' => '诊疗号',
            'drug_name' => '药名',
            'drug_num' => '数量',
            'drug_unit' => '单位',
            'drug_type' => '类型',
            'price' => '单价',
            'money' => '金额',
            'discount_rate' => '折扣率（0.80,代表8折）',
            'reality_money' => '折扣后金额',
            'consumption_type' => '消费类型： 1：消费 2：入库（已退货）',
            'remark' => '备注',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',
        ];
    }
}
